<?php
namespace App\Http\Controllers\Shop;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class MountController extends Controller{
    public function mount_show(){
        $info=DB::table("shop_mount")->get();
        return view("Mount/index",['info'=>$info]);
    }
    public function  mount_add(Request $r){
        $data=$r->except('_token');
        if ($r->hasFile('images')) {
            $file = $r->file('images');
            $file->move('uploads/Mount', $file->getClientOriginalName());
            $data['images'] = 'http://www.huyaa.com/uploads/Mount/' . $file->getClientOriginalName();
        }
        if ($r->hasFile('gif_images')) {
            $file = $r->file('gif_images');
            $file->move('uploads/MountGIF', $file->getClientOriginalName());
            $data['gif_images'] ='http://www.huyaa.com/uploads/MountGIF/' . $file->getClientOriginalName();
        }
        $data['c_imgtime']=date('Y-m-d H:i:s', time());
        $info=DB::table('shop_mount')->insert($data);
        if($info){
            return redirect('mount_show');
        }
    }
    public function mount_delete($id){
        $info=DB::table("shop_mount")->where("id",$id)->delete();
        if($info){
            return redirect("mount_show");
        }else{
            echo "删除失败";
        }
    }
}